package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmChapterMapper;
import cn.mcartoon.pojo.MmChapter;
import cn.mcartoon.service.MmChapterService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmChapterServiceImpl implements MmChapterService {

    @Autowired
    private MmChapterMapper mmChapterMapper;

    public MmChapter getMmChapterById(Long id){
        return mmChapterMapper.getMmChapterById(id);
    }

    public List<MmChapter>	getMmChapterListByMap(Map<String,Object> param){
        return mmChapterMapper.getMmChapterListByMap(param);
    }

    public Integer getMmChapterCountByMap(Map<String,Object> param){
        return mmChapterMapper.getMmChapterCountByMap(param);
    }

    public Integer insertMmChapter(MmChapter mmChapter){
            return mmChapterMapper.insertMmChapter(mmChapter);
    }

    public Integer updateMmChapter(MmChapter mmChapter){
        return mmChapterMapper.updateMmChapter(mmChapter);
    }

    public Integer deleteMmChapterById(Long id){
        return mmChapterMapper.deleteMmChapterById(id);
    }

    public Integer batchDeleteMmChapter(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmChapterMapper.batchDeleteMmChapter(param);
    }

    public Page<MmChapter> queryMmChapterPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmChapterMapper.getMmChapterCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmChapter> mmChapterList = mmChapterMapper.getMmChapterListByMap(param);
        page.setList(mmChapterList);
        return page;
     }


}
